#!/usr/bin/env python
#coding=utf-8
import parse
import threading
import wx

class EmailThread(threading.Thread):  
    def __init__(self, window, web, inviteUrl, email):
        threading.Thread.__init__(self)
        self.window = window
        self.web = web
        self.inviteUrl = inviteUrl
        self.email = email
    
    def run(self): 
        f = self.web.existsEmail(self.inviteUrl['id'], self.inviteUrl['code'], self.email)
        hasEmail = parse.parseEmail(f)
        
        if hasEmail != -1:
            if hasEmail:
                wx.CallAfter(self.window.messageCall, u'邮箱已存在，自动更换')
                wx.CallAfter(self.window.emailCall)
            else:
                wx.CallAfter(self.window.emailSucessCall)
        else:
            wx.CallAfter(self.window.messageCall, u'获取验证码地址失败')
            
